* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Courier New", Courier, monospace;
  background: #7fc4b2;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.35), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(30,90,80,0.35), transparent 50%),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.02) 0 12px, transparent 12px 24px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 8px 24px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#wrap { width: 100%; max-width: 430px; display: flex; flex-direction: column; align-items: center; gap: 10px; }

#device {
  width: 100%;
  background: linear-gradient(160deg, #f2836b 0%, #e8695f 45%, #d15149 100%);
  border-radius: 46px 46px 60px 60px;
  padding: 18px 16px 26px;
  box-shadow:
    inset 0 3px 6px rgba(255,255,255,0.55),
    inset 0 -8px 14px rgba(120,20,20,0.35),
    0 14px 30px rgba(0,40,35,0.45),
    0 3px 0 #a83f39;
  position: relative;
}

.brand {
  text-align: center;
  color: #7c1f1f;
  font-weight: bold;
  font-size: 15px;
  letter-spacing: 2px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  margin-bottom: 12px;
}
.brand span { font-size: 10px; vertical-align: super; }

#bezel {
  background: linear-gradient(170deg, #5a3d3a, #43292a);
  border-radius: 24px;
  padding: 12px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.25);
}

#lcd {
  position: relative;
  background: #bfe3d8;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 168 / 144;
  box-shadow: inset 0 0 14px rgba(20,60,50,0.4);
}

#lcdCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(20,40,35,0.10) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  animation: flicker 4s infinite steps(60);
  z-index: 30;
}

.glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.08) 18%, transparent 32%);
  z-index: 31;
}

@keyframes flicker {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 3px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 9px;
  color: #1d3a2e;
  pointer-events: none;
}
#hud button { pointer-events: auto; }

.hud-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.hud-tabs { display: flex; gap: 3px; }
.hud-tabs .tab {
  width: 15px; height: 15px;
  font-family: inherit; font-size: 9px; font-weight: bold;
  border: 1px solid #1d3a2e; background: rgba(255,255,255,0.4); color: #1d3a2e;
  border-radius: 3px; cursor: pointer;
}
.hud-tabs .tab.on { background: #1d3a2e; color: #bfe3d8; }
.hud-name { font-weight: bold; }
.hud-mood { opacity: 0.85; }
.wicon { width: 12px; height: 12px; image-rendering: pixelated; vertical-align: -2px; }
.hud-clock { margin-left: auto; font-weight: bold; }

.hud-bars { display: flex; gap: 4px; flex-wrap: wrap; }
.bar { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,0.35); border-radius: 3px; padding: 1px 3px; }
.bar img { width: 11px; height: 11px; image-rendering: pixelated; }
.bar i { width: 6px; height: 7px; display: inline-block; background: rgba(29,58,46,0.2); margin-right: 1px; }
.bar i.on { background: #1d6a4a; }

.hud-mini { font-size: 9px; }
.hud-mini .mini {
  font-family: inherit; font-size: 9px;
  background: rgba(255,255,255,0.5); border: 1px solid #1d3a2e;
  border-radius: 3px; color: #1d3a2e; padding: 0 4px; cursor: pointer;
}

#ticker {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  background: rgba(29,58,46,0.82);
  color: #d8f2e4;
  font-size: 10px;
  line-height: 1.35;
  padding: 3px 6px;
  max-height: 44px;
  overflow: hidden;
}

#toasts {
  position: absolute;
  top: 42%;
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.toast {
  background: #1d3a2e;
  color: #f4f0e6;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 10px;
  border: 2px solid #d8f2e4;
  animation: pop 0.25s ease-out;
  max-width: 90%;
  text-align: center;
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#overlay { position: absolute; inset: 0; z-index: 15; display: none; }
#overlay.visible { display: block; }
#overlay.transparent { background: transparent; }
#overlay.visible:not(.transparent) { background: rgba(29,58,46,0.25); }
#overlay.gamemode { background: transparent; }

.panel {
  position: absolute;
  inset: 0;
  background: rgba(191,227,216,0.96);
  padding: 26px 8px 40px;
  overflow-y: auto;
  color: #1d3a2e;
  font-size: 11px;
}
#overlay.transparent .panel.main-panel {
  top: auto;
  height: auto;
  max-height: 45%;
  background: rgba(191,227,216,0.92);
  border-radius: 10px 10px 0 0;
  border-top: 2px solid #1d3a2e;
}
#overlay.gamemode .game-panel { background: transparent; padding: 24px 6px 8px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; }

.title { font-size: 13px; font-weight: bold; letter-spacing: 1px; margin-bottom: 6px; border-bottom: 2px dashed rgba(29,58,46,0.4); padding-bottom: 4px; }
.coins { float: right; }

.msg { margin: 3px 0; line-height: 1.4; }
.msg.big-msg { font-size: 13px; margin: 10px 4px; }
.warn { color: #a03030; font-weight: bold; margin: 3px 0; }
.hint { font-size: 10px; opacity: 0.8; margin: 6px 2px; line-height: 1.4; }

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  background: #1d6a4a;
  color: #eafff2;
  border: 2px solid #1d3a2e;
  border-radius: 8px;
  padding: 5px 10px;
  margin: 3px 2px;
  cursor: pointer;
  letter-spacing: 1px;
}
.btn.ok { background: #e8695f; }
.btn:active, .btn.cursor { outline: 2px solid #e2554d; outline-offset: 1px; transform: translateY(1px); }

.btnrow { display: flex; justify-content: space-between; margin-top: 6px; }

.list { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(29,58,46,0.35);
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
}
.row img { width: 22px; height: 22px; image-rendering: pixelated; }
.row.done { background: rgba(87,179,91,0.35); }
.row.off { opacity: 0.45; }
.rname { font-weight: bold; white-space: nowrap; }
.cnt { font-size: 10px; opacity: 0.85; margin-left: auto; text-align: right; }
.row .cnt { max-width: 55%; }
.price { font-weight: bold; color: #8a5a2a; }
.act { font-size: 9px; background: #1d6a4a; color: #eafff2; border-radius: 4px; padding: 1px 5px; }
.ok { width: 14px !important; height: 14px !important; }
.lock { width: 20px !important; height: 20px !important; opacity: 0.6; }

.tabs { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.tab2 {
  font-family: inherit; font-size: 10px; font-weight: bold;
  background: rgba(255,255,255,0.6); border: 1px solid #1d3a2e; color: #1d3a2e;
  border-radius: 6px; padding: 2px 7px; cursor: pointer;
}
.tab2.on { background: #1d3a2e; color: #d8f2e4; }
.tab2.cursor { outline: 2px solid #e2554d; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; margin: 4px 0; }
.st { display: flex; align-items: center; gap: 3px; font-size: 10px; }
.st b { width: 92px; font-weight: bold; }
.st i { font-style: normal; width: 22px; text-align: right; }

.mbtn { display: flex; align-items: center; gap: 6px; width: calc(50% - 4px); margin: 2px; }
.mbtn img { width: 16px; height: 16px; image-rendering: pixelated; }

.eggs { display: flex; justify-content: space-around; margin: 10px 0; }
.egg { display: flex; flex-direction: column; align-items: center; cursor: pointer; font-weight: bold; gap: 4px; }
.egg canvas { width: 58px; height: 58px; image-rendering: pixelated; background: rgba(255,255,255,0.4); border-radius: 10px; border: 2px solid rgba(29,58,46,0.4); }
.egg.cursor canvas, .egg:active canvas { border-color: #e2554d; }

.cgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 6px 0; }
.card {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(29,58,46,0.35);
  border-radius: 8px;
  padding: 4px 2px;
  cursor: pointer;
  text-align: center;
}
.card img { width: 40px; height: 40px; image-rendering: pixelated; }
.cname { font-weight: bold; font-size: 10px; }
.crar { font-size: 9px; }
.r-common { color: #4a6a4a; }
.r-uncommon { color: #2a6a8a; }
.r-rare { color: #6a4aa8; }
.r-epic { color: #a84a8a; }
.r-legend { color: #a8742a; font-weight: bold; }
.card.cursor, .card:active { outline: 2px solid #e2554d; }

.inrow { display: flex; gap: 6px; margin: 8px 0; }
#petName {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border: 2px solid #1d3a2e;
  border-radius: 8px;
  background: #f4f0e6;
  color: #1d3a2e;
}
.big { width: 64px; height: 64px; image-rendering: pixelated; display: block; margin: 4px auto; }

.boot-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.boot-logo {
  font-size: 26px;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 3px;
  color: #1d3a2e;
  text-shadow: 2px 2px 0 rgba(232,105,95,0.5);
  animation: bootpulse 1.6s infinite;
}
@keyframes bootpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.touch { display: flex; justify-content: center; gap: 8px; margin: 4px 0; }
.tbtn {
  width: 44px; height: 44px;
  font-size: 18px;
  font-family: inherit;
  background: rgba(29,58,46,0.85);
  color: #d8f2e4;
  border: 2px solid #d8f2e4;
  border-radius: 50%;
  cursor: pointer;
}
.tbtn.act { background: #e8695f; border-color: #fff; width: 54px; height: 54px; }
.tbtn:active { transform: scale(0.92); }
#gameExit { align-self: center; }

#abc { display: flex; justify-content: center; gap: 26px; margin: 16px 0 6px; }
.abc-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #ffd9c9, #d15149 70%);
  box-shadow: 0 4px 0 #8a2f2a, inset 0 2px 3px rgba(255,255,255,0.6);
  color: #7c1f1f;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.abc-btn span { font-size: 18px; font-weight: bold; }
.abc-btn em { font-style: normal; font-size: 8px; letter-spacing: 1px; }
.abc-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a2f2a; }

#pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 10px;
}
#pad button {
  font-family: inherit;
  font-size: 9px;
  background: linear-gradient(170deg, #ffd9c9, #f0a898);
  color: #6a2018;
  border: none;
  border-radius: 10px;
  padding: 6px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 3px 0 rgba(140,50,40,0.6), inset 0 1px 2px rgba(255,255,255,0.7);
}
#pad button img { width: 18px; height: 18px; image-rendering: pixelated; }
#pad button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(140,50,40,0.6); }

.speaker {
  position: absolute;
  bottom: 26px;
  right: 30px;
  display: flex;
  gap: 5px;
  transform: rotate(-25deg);
}
.speaker i { width: 5px; height: 26px; background: rgba(90,20,20,0.5); border-radius: 3px; }

#footnote { font-size: 11px; color: rgba(20,60,50,0.8); text-align: center; line-height: 1.4; }

@media (max-width: 480px) {
  #device { border-radius: 34px 34px 44px 44px; padding: 12px 10px 20px; }
  #pad { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  #pad button { font-size: 8px; padding: 4px 1px; border-radius: 8px; }
  #abc { gap: 20px; }
  .abc-btn { width: 52px; height: 52px; }
  .speaker { display: none; }
}

@media (min-width: 700px) {
  #wrap { max-width: 460px; }
}
