/* Wordiculum online refresh — shared website shell + authentic game-state cues */

:root {
  --bg: #0d1015;
  --surface: #1a1d24;
  --surface-raised: #22262e;
  --tile-bg: #26343a;
  --tile-border: #a9b0b5;
  --tile-selected: #ff9a42;
  --tile-correct: #35ad64;
  --tile-invalid: #e65353;
  --tile-adjacent: #ff9a42;
  --text: #f5f6f7;
  --text-muted: #9da8b2;
  --accent: #ff68a5;
  --accent-blue: #5d9dd2;
  --accent-glow: rgba(255, 104, 165, 0.3);
  --tile-size: min(18vw, 90px);
  --gap: 7px;
  --radius: 13px;
  --panel-border: rgba(190, 202, 212, 0.18);
  --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

html {
  min-width: 280px;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 14% -10%, rgba(255, 104, 165, 0.15), transparent 32rem),
    radial-gradient(circle at 86% 0%, rgba(62, 123, 177, 0.17), transparent 34rem),
    linear-gradient(180deg, #11141a 0%, #0b0e12 72%);
}

button,
summary,
.tile {
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
}

/* Website-family masthead */
#header {
  display: block;
  padding: 0;
  background: rgba(13, 16, 21, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

#header-inner {
  width: min(1180px, 100%);
  min-height: 78px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

#logo {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  text-decoration: none;
  background: none;
  -webkit-text-fill-color: initial;
  filter: none;
}

#logo img {
  display: block;
  width: clamp(150px, 18vw, 225px);
  max-height: 55px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.34));
}

#logo span {
  color: #91bde0;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.16em;
  white-space: nowrap;
  padding: 7px 9px 6px;
  border: 1px solid rgba(93, 157, 210, 0.45);
  border-radius: 999px;
  background: rgba(93, 157, 210, 0.1);
}

#header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#header-right button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: #e9edf1;
  font-family: var(--font-main);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}

#header-right button:hover,
#header-right button:focus-visible {
  border-color: rgba(255, 104, 165, 0.72);
  background: rgba(255, 104, 165, 0.08);
  transform: translateY(-1px);
  outline: none;
}

#btn-new-game {
  background: linear-gradient(135deg, #ff76ae, #ff5798) !important;
  border-color: #ff76ae !important;
  color: #17151a !important;
  box-shadow: 0 8px 24px rgba(255, 87, 152, 0.22) !important;
}

#btn-end-game {
  border-color: rgba(230, 83, 83, 0.5) !important;
  color: #ff8f8f !important;
}

/* Two-panel play surface */
#main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(420px, 490px) minmax(280px, 1fr);
  align-items: stretch;
  gap: 18px;
  overflow: visible;
}

#game-panel,
#info-panel {
  min-width: 0;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(31, 35, 43, 0.96), rgba(20, 23, 29, 0.97));
  box-shadow: var(--panel-shadow);
}

#game-panel {
  width: 100%;
  padding: 18px;
  gap: 11px;
  position: relative;
  overflow: hidden;
}

#game-panel::before,
#info-panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #ff68a5, #7b78dc 52%, #5d9dd2);
  pointer-events: none;
}

#game-heading {
  width: 100%;
  padding: 2px 2px 0;
}

#game-heading > span {
  display: block;
  color: #ff83b4;
  font-family: var(--font-main);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.17em;
}

#game-heading p {
  margin-top: 5px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.45;
}

#score-bar {
  width: 100%;
  min-height: 47px;
  margin-top: 1px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(93, 157, 210, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(33, 81, 120, 0.72), rgba(31, 53, 82, 0.55)),
    #17212d;
  color: #dce9f4;
  box-shadow: inset 0 0 26px rgba(93, 157, 210, 0.08);
}

#score-display {
  color: #fff;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
}

#word-count-display {
  color: #a9c8e2;
  font-size: 0.76rem;
  white-space: nowrap;
}

#grid-area {
  width: 100%;
  justify-content: center;
  gap: 10px;
  padding: 2px 0 0;
}

#grid {
  position: relative;
  isolation: isolate;
  touch-action: none;
}

.tile {
  position: relative;
  overflow: visible;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 48%),
    var(--tile-bg);
  border: 1.5px solid var(--tile-border);
  border-radius: var(--radius);
  color: #f8f8f8;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 5px 10px rgba(0, 0, 0, 0.19);
  font-size: initial;
  outline: none;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    border-radius 0.55s ease,
    color 0.25s ease,
    transform 0.1s ease,
    box-shadow 0.18s ease,
    opacity 0.25s ease;
}

.tile-letter {
  position: relative;
  z-index: 1;
  font-family: var(--font-main);
  font-size: calc(var(--tile-size) * 0.42);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
}

.tile-die-id {
  position: absolute;
  left: 9%;
  bottom: 6%;
  z-index: 2;
  color: #7f8c95;
  font-family: var(--font-main);
  font-size: calc(var(--tile-size) * 0.18);
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
}

.tile-use-count {
  position: absolute;
  top: -7%;
  right: -6%;
  z-index: 4;
  width: calc(var(--tile-size) * 0.34);
  height: calc(var(--tile-size) * 0.34);
  min-width: 22px;
  min-height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(202, 222, 239, 0.4);
  background: rgba(93, 157, 210, 0.94);
  color: #1b2731;
  font-family: var(--font-main);
  font-size: calc(var(--tile-size) * 0.17);
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transform: scale(0.72);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  box-shadow: 0 5px 14px rgba(38, 91, 136, 0.34);
}

.tile.selected .tile-use-count,
.tile.correct .tile-use-count,
.tile.invalid .tile-use-count,
.tile:focus-visible .tile-use-count {
  opacity: 1;
  transform: scale(1);
}

/* One corner becomes a full radius for each step toward death. */
.tile[data-uses="3"],
.mechanic-tile[data-uses="3"] {
  border-radius: var(--radius) 50% var(--radius) var(--radius);
}

.tile[data-uses="2"],
.mechanic-tile[data-uses="2"] {
  border-radius: var(--radius) 50% 50% var(--radius);
}

.tile[data-uses="1"],
.mechanic-tile[data-uses="1"] {
  border-radius: 50% 50% 50% var(--radius);
}

.tile[data-uses="0"],
.mechanic-tile[data-uses="0"] {
  border-radius: 50%;
  background: #b7bac1;
  border-color: #c7c9cf;
  color: #25272c;
  cursor: default;
  opacity: 1;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.18), 0 5px 12px rgba(0, 0, 0, 0.18);
}

.tile[data-uses="0"] .tile-die-id,
.mechanic-tile[data-uses="0"] .tile-die-id {
  color: #747981;
}

@media (hover: hover) {
  .tile:not([data-uses="0"]):hover {
    border-color: #d0d5d9;
    box-shadow: 0 0 0 2px rgba(93, 157, 210, 0.18), 0 7px 16px rgba(0, 0, 0, 0.24);
  }
}

.tile.selected {
  z-index: 3;
  background: linear-gradient(145deg, #ffb260, #ff9140);
  border-color: #ffd19b;
  color: #211b16;
  transform: scale(0.95);
  box-shadow: 0 0 0 2px rgba(255, 154, 66, 0.28), 0 0 22px rgba(255, 154, 66, 0.34);
}

.tile.selected .tile-die-id {
  color: rgba(53, 37, 24, 0.56);
}

.tile[data-uses="0"].selected {
  background: #c0c3c9;
  border-color: #74a9d4;
  color: #25272c;
  box-shadow: 0 0 0 3px rgba(93, 157, 210, 0.3);
}

.tile.adjacent {
  opacity: 1;
  border: 1.5px dashed #ffb66f;
  box-shadow: inset 0 0 0 2px rgba(255, 154, 66, 0.08);
}

.tile.correct {
  background: linear-gradient(145deg, #47c375, #2e9b58);
  border-color: #9ee7b8;
  color: #0d2817;
  box-shadow: 0 0 18px rgba(53, 173, 100, 0.35);
}

.tile.invalid {
  background: linear-gradient(145deg, #ef6868, #c94242);
  border-color: #ffb0b0;
  color: #2b1111;
}

#big-word-tracker {
  width: 25px;
}

#tracker-bar-outer {
  width: 18px;
  background: #121820;
  border-color: rgba(157, 168, 178, 0.42);
}

#tracker-label {
  color: #8cc37e;
  font-size: 7px;
}

#current-word-display {
  width: 100%;
  min-height: 45px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 9px;
  background: rgba(4, 7, 11, 0.48);
  color: #ffae67;
  font-size: 1.25rem;
  text-shadow: 0 0 13px rgba(255, 154, 66, 0.28);
}

#current-word-display:empty::before {
  content: 'Trace or tap a word';
  color: #68727c;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  text-shadow: none;
}

#message-display {
  min-height: 20px;
  color: #aeb9c2;
}

#action-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr 0.9fr;
  gap: 7px;
}

#action-bar button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 9px;
  background: #20242b;
  color: #e2e7eb;
  font-family: var(--font-main);
  font-size: 0.73rem;
}

#action-bar button:hover,
#action-bar button:focus-visible {
  border-color: rgba(255, 154, 66, 0.8);
  transform: translateY(-1px);
  outline: none;
}

#btn-submit {
  background: linear-gradient(135deg, #ffad62, #ff9140);
  border-color: #ffb774;
  color: #221a13;
  box-shadow: 0 7px 20px rgba(255, 145, 64, 0.2);
}

#btn-hint:not(:disabled) {
  border-color: #78b7dc;
  color: #a8d5f0;
}

/* Found words, definitions and mechanic key */
#info-panel {
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(155px, 1fr) auto auto;
  gap: 11px;
  overflow: hidden;
  position: relative;
}

#found-words-header {
  padding-top: 3px;
  color: #ff83b4;
  font-family: var(--font-main);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

#found-words-header::after {
  content: ' // CLICK A WORD FOR ITS DEFINITION';
  color: #6e7a85;
  font-size: 0.62rem;
}

#found-words-list {
  min-height: 155px;
  padding-right: 4px;
  gap: 5px;
}

#found-words-list:empty::before {
  content: 'Your accepted words will appear here.';
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 25px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #69747e;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  text-align: center;
}

.found-word-item {
  min-height: 38px;
  padding: 7px 10px;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.found-word-item:hover {
  border-color: rgba(255, 104, 165, 0.62);
  background: rgba(255, 104, 165, 0.06);
}

#definition-display {
  min-height: 66px;
  max-height: 128px;
  padding: 12px;
  border-color: rgba(93, 157, 210, 0.25);
  border-radius: 11px;
  background: rgba(22, 33, 45, 0.56);
  color: #aebfcd;
}

#definition-display:empty::before {
  content: 'Select a found word to read its definition.';
  color: #687783;
}

.empty-panel-copy {
  color: #687783;
}

#tile-life-guide {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(6, 9, 13, 0.34);
  overflow: hidden;
}

#tile-life-guide summary {
  min-height: 48px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: #e8edf1;
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#tile-life-guide summary::-webkit-details-marker {
  display: none;
}

#tile-life-guide summary::after {
  content: '+';
  color: #ff79ad;
  font-size: 1.15rem;
  line-height: 1;
}

#tile-life-guide[open] summary::after {
  content: '−';
}

#tile-life-guide summary small {
  margin-left: auto;
  color: #73808a;
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 400;
  text-align: right;
}

.tile-life-stages {
  padding: 4px 12px 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(55px, 1fr));
  gap: 7px;
}

.tile-life-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: #87939d;
  font-family: var(--font-ui);
  font-size: 0.62rem;
  text-align: center;
}

.mechanic-tile {
  --preview-size: 54px;
  width: var(--preview-size);
  height: var(--preview-size);
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  background: var(--tile-bg);
  color: #f8f8f8;
}

.mechanic-tile .tile-letter {
  font-size: 1.35rem;
}

.mechanic-tile .tile-die-id {
  left: 6px;
  bottom: 4px;
  font-size: 0.6rem;
}

.mechanic-tile .tile-use-count {
  width: 21px;
  height: 21px;
  min-width: 21px;
  min-height: 21px;
  top: -4px;
  right: -4px;
  opacity: 1;
  transform: none;
  font-size: 0.58rem;
}

.tile-life-explainer {
  margin: 0 13px 13px;
  color: #7f8b95;
  font-family: var(--font-ui);
  font-size: 0.67rem;
  line-height: 1.48;
}

/* Existing dialogs now use the same material language. */
#modal-overlay {
  background: rgba(3, 5, 8, 0.82);
  backdrop-filter: blur(10px);
}

#modal-content {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  background: linear-gradient(180deg, #22262e, #171a20);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
}

.modal-title {
  color: #ff79ad;
}

#loading-screen {
  background:
    radial-gradient(circle at center, rgba(93, 157, 210, 0.12), transparent 30rem),
    #0d1015;
}

/* Tablet and narrow desktop */
@media (max-width: 900px) {
  #main {
    width: min(680px, 100%);
    grid-template-columns: 1fr;
    padding: 16px;
  }

  #info-panel {
    min-height: 470px;
    max-height: none;
    overflow: visible;
    grid-template-rows: auto minmax(180px, 250px) auto auto;
  }
}

/* Phone layout remains fully playable and scrollable. */
@media (max-width: 600px) {
  :root {
    --gap: 5px;
    --radius: 10px;
  }

  #header-inner {
    min-height: 0;
    padding: 8px 10px 9px;
    align-items: center;
    gap: 8px;
  }

  #logo {
    gap: 7px;
  }

  #logo img {
    width: clamp(118px, 38vw, 155px);
    max-height: 42px;
  }

  #logo span {
    display: none;
  }

  #header-right {
    gap: 5px;
    flex-wrap: nowrap;
  }

  #header-right button {
    min-width: 38px;
    min-height: 38px;
    padding: 6px 9px;
  }

  .utility-label {
    display: none;
  }

  #btn-end-game {
    display: none;
  }

  #btn-new-game {
    font-size: 0.68rem !important;
  }

  #main {
    width: 100%;
    padding: 10px;
    gap: 12px;
  }

  #game-panel,
  #info-panel {
    border-radius: 14px;
  }

  #game-panel {
    padding: 12px;
    gap: 8px;
  }

  #game-heading > span {
    font-size: 0.65rem;
  }

  #game-heading p {
    font-size: 0.7rem;
  }

  #score-bar {
    min-height: 42px;
    padding: 0 10px;
  }

  #score-display {
    font-size: 0.88rem;
  }

  #word-count-display {
    font-size: 0.68rem;
  }

  #grid-area {
    gap: 7px;
  }

  .tile-die-id {
    left: 8%;
    bottom: 6%;
  }

  #current-word-display {
    min-height: 40px;
    padding: 7px 9px;
    font-size: 1.05rem;
  }

  #action-bar {
    grid-template-columns: 1fr 1.25fr;
  }

  #action-bar button {
    min-height: 40px;
  }

  #info-panel {
    min-height: 0;
    padding: 14px;
    grid-template-rows: auto minmax(160px, 220px) auto auto;
  }

  #found-words-header::after {
    display: none;
  }

  #tile-life-guide summary {
    align-items: flex-start;
  }

  #tile-life-guide summary small {
    display: none;
  }

  .tile-life-stages {
    grid-template-columns: repeat(3, 1fr);
    row-gap: 12px;
  }
}

@media (max-width: 350px) {
  #game-heading p {
    display: none;
  }

  #header-right button {
    padding-inline: 7px;
  }

  #btn-new-game {
    font-size: 0.62rem !important;
  }

  #game-panel {
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
