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

.hidden {
  display: none !important;
}

:root {
  --bg: #ffffff;
  --text: #13222b;
  --muted: rgba(0, 0, 0, 0.55);
  --shell-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--shell-font);
  background: var(--bg);
  min-height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  width: 100vw;
  background: var(--bg);
}

#game-area {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

#game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  z-index: 1;
}

/* Error message */
.error-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  padding: 16px 24px;
  background: rgba(220, 53, 69, 0.92);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  max-width: 80%;
}

/* Control Bar */
#control-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border-top: none;
  font-family: var(--shell-font);
  z-index: 10;
  overflow: visible;
}

.cb-left {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
}

.cb-center {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cb-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  flex: 1;
}

.cb-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.cb-icon-btn:active {
  opacity: 0.5;
}

.cb-icon-btn svg {
  width: 19px;
  height: 19px;
}

.cb-hint-btn {
  position: relative;
}

.cb-hint-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--shell-font);
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

.cb-hint-btn.disabled {
  opacity: 0.25;
  pointer-events: none;
}

.cb-powered {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  margin-left: 4px;
  white-space: nowrap;
}

.cb-powered-label {
  font-size: 7px;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.22);
}

.cb-powered strong {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: rgba(0, 0, 0, 0.4);
}

/* Modal */
/* Modals must be above endscreen (z-index 6000) */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7000;
}

.modal-panel {
  width: min(380px, calc(100vw - 32px));
  background: #fff;
  border: 2px solid var(--text);
  box-shadow: 4px 4px 0px var(--text);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  text-transform: uppercase;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.modal-close-btn:active {
  opacity: 0.5;
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 0 20px 20px;
}

.modal-text-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-text-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 20px;
}

.modal-btn {
  padding: 10px 16px;
  border: 2px solid var(--text);
  background: #fff;
  color: var(--text);
  font-family: var(--shell-font);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--text);
  text-transform: uppercase;
}

.modal-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.modal-btn-danger {
  background: var(--text);
  color: #fff;
}

/* Username input */
.username-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.username-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--text);
  background: #fff;
  font-family: var(--shell-font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  outline: none;
}

.username-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

